package com.example.user.service.domain;

import com.example.user.service.common.IdWorker;
import com.example.user.service.domain.port.GetUserListPort;
import com.example.user.service.domain.valueobject.Email;
import com.example.user.service.domain.valueobject.UserAge;
import com.example.user.service.domain.valueobject.UserId;
import com.example.user.service.domain.valueobject.UserName;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;

import java.util.List;

@Setter
@Getter
@ToString
public class User {
    private UserId id;
    private UserName name;
    private UserAge age;
    private Email email;

    public User() {
    }

    public User(UserId id, UserName name, UserAge age, Email email) {
        this.id = id;
        this.name = name;
        this.age = age;
        this.email = email;
    }

    public User( UserName name, UserAge age, Email email) {
        this.id= genId() ;
        this.name = name;
        this.age = age;
        this.email = email;
    }

    public static List<User> getUsers(GetUserListPort getUserListPort){
        return getUserListPort.getUsers();
    }

    public UserId genId(){
        return new UserId(new IdWorker().nextId());
    }
}
